

<div align='center' id='newsButtonDiv' style="display: none">
    <input class='btn-style02' type='button'  value='全选'/>
    <input class='btn-style02' type='button'  value='关闭' onclick=' window.close();'/>
</div>


<script type="text/javascript">

    function loadUnreadNews(){
        $.ajax({
            url: 'loadUnreadNews.do',
            type: "POST",
            data: {},
            cache: false,
            error:function(){
                alert('连接服务器失败，请重新登录！');
            },
            success: function(msg){
                if(!msg||msg.length==0){
                    return false;
                }
                $("#newsButtonDiv").show();
                var $newsDialog = $("#dialog-news");
                if($newsDialog.size()==0){
                    $.ajaxSetup({async:false});
                    $newsDialog = $("<div id='dialog-news'/>").css({overflowY:'scroll'}).appendTo("body");
                }
                $.each(msg||[],function(k,v){
                    var fileInfos = v.FILE_INFO?v.FILE_INFO.split(","):'' ;
                    var fileStr = "";
                    if(fileInfos){
                        fileStr = '</br><span  style="color:blue;font-weight:bold;">[附件]</span>';
                    }
                    var fileIds = [] ;
                    var fileNames =[] ;
                    var filePaths = [] ;
                    $.each(fileInfos||[],function(key,val){
                        if(val.indexOf("@")>=0){
                            var arr = val.split("@");
                            fileIds.push(arr[0]);
                            fileNames.push(decodeURIComponent(arr[1]));
                            filePaths.push(arr[2]);
                        }
                    })


                    $.each(fileIds||[],function(key,val){
                        var url = 'download.do?savePath='+ encodeURIComponent(filePaths[key])+'&fileFileName='+encodeURIComponent(fileNames[key]);
                        fileStr = fileStr+"</br>"+ "<a href="+url+" >"+fileNames[key]+"</a>"
                    })

                    $newsDialog.append(
                            "<div style='font-weight:bold;color:blue'>"+ v.PUBLISH_TIME+"&nbsp;["+ v.NAME+"]:&nbsp;"+(v.TITLE?v.TITLE:'')+
                                    "<div style='display: block;float:right;'><input type='checkbox' name='newsids' value="+v.NEWS_ID+" />不再提示&nbsp;</div></div>"+
                                    "<pre>"+ (v.CONTENT?v.CONTENT:'')+fileStr+"</pre>"
                    )
                })
                $newsDialog.append(
                        "<br/><div  id='buttonDiv' style='position:absolute;bottom:10px;left:350px;'></div>"
                )
                $("<input class='btn-style02' type='button'  value='全选'/>").toggle(
                        function () {
                            $("[name=newsids]").attr("checked","checked");
                        },
                        function () {
                            $("[name=newsids]").attr("checked",false);
                        }
                ).appendTo("#buttonDiv");
                $("<input class='btn-style02' type='button'  value='确定'/>").click(function(){
                    var ids = [];
                    $("[name=newsids]:checked").each(function(k,v){
                        ids.push($(v).val())
                    })
                    if(ids.length>0){
                        $.ajax({
                            url: 'readNews.do',
                            type: "POST",
                            data: {ids:ids},
                            cache: false,
                            error:function(){
                                alert('标记失败');
                            },
                            success: function(msg){
                                $newsDialog.dialog('close');
                            }
                        })
                    }else{
                        $newsDialog.dialog('close');
                    }
                }).appendTo("#buttonDiv");
                $newsDialog.dialog({
                    title: '尊敬的用户,您有 '+(msg?msg.length:0)+' 条未读公告',
                    modal: true,
                    width: 800,
                    height: 600,
                    resizable: false,
                    beforeclose:function(){
                        $(this).dialog("destory");
                    }
                });

            }
        });
    }
	
</script>
